package se.webbzon.boltzmann.game.event;

import se.webbzon.boltzmann.game.switchable.Switchable;
import se.webbzon.oschi01.worldarea.WorldArea;
import se.webbzon.oschi01.worldobject.WorldObject;

public class SetEnableEvent extends AbstractGameEvent {
	
	// The binding of this game event
	private final WorldObject binding;
	
	// Whatever this event is to set enable and instant
	private boolean enable, instant;

	/*============================================================
	Constructors
	============================================================*/
	
	/** Creates a new sleep game event. **/
	public SetEnableEvent(	WorldObject binding,
							boolean enable, boolean instant) {
		this.binding = binding;
		this.enable = enable;
		this.instant = instant;
	}
	
	/*============================================================
	Public Methods
	============================================================*/

	@Override protected void onBegin(WorldArea world) {
		if (binding instanceof Switchable) {
			((Switchable) binding).setEnable(enable, instant);
		} else
			exception("Argument exception.");
		end();
	}

	@Override protected void onEnd() {};

}
